import { HttpException } from '@nestjs/common';
import { HTTP_CODE } from '../enum/http-code.enum';
import { ErrMsgDetailType } from '../type/response.type';
export class BusinessException extends HttpException {
    private _msg: string; // 自定义信息
    private _code: string; // 自定义编码

    constructor(type: ErrMsgDetailType, msg?: string) {
        super({ message: msg, statusCode: 200 }, HTTP_CODE.SUCCESS, { cause: type.msg, description: msg });
        // 自定义信息及编码
        this._msg = type.msg + `${msg ? ' - ' + msg : ''}`;
        this._code = type.code;
    }

    public get getMsg(): string {
        return this._msg;
    }
    public get getCode(): string {
        return this._code;
    }
}
